package com.cloudsigns.factorymanager2.produce.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.IProductNormalFeedbackConfirmView;
import com.cloudsigns.factorymanager2.produce.model.IProductNormalFeedbackConfirmModel;
import com.cloudsigns.factorymanager2.produce.model.ProductNormalFeedbackConfirmModel;

public class ProductNormalFeedbackConfirmPresenter {
    private IProductNormalFeedbackConfirmView view;
    private IProductNormalFeedbackConfirmModel model;
    private Handler handler = new Handler();

    public ProductNormalFeedbackConfirmPresenter(IProductNormalFeedbackConfirmView view) {
        this.view = view;
        this.model = new ProductNormalFeedbackConfirmModel();
    }

    public void productNormalFeedbackConfirm() {
        model.productNormalFeedbackConfirm(view.getOrderId(), view.getProductId(), view.getWorkPartFeedbackId(), view.getWorkPartId(), view.getWorkPartOrderId(), new ProductNormalFeedbackConfirmModel.OnProductNormalFeedbackConfirmListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getProductNormalFeedbackConfirmSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getProductNormalFeedbackConfirmFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
